/*
 * Brain.hpp
 *
 *  Created on: 04-01-2011
 *      Author: Piotr
 */

#pragma once

#include "biology/Genotype.hpp"
#include "biology/State.hpp"
#include "world/World.hpp"
#include "world/Supply.hpp"
#include "pch.hpp"

class Thought;
class Individual;
class WaterSupply;

using std::vector;

/*
 * A thinking object which every individual has. It decides what the next move action will be by generating
 * thoughts.
 */
class Brain
{
	private:
		float closestElement;
		float onTheLeft;
		float inTheCenter;
		float onTheRight;

	public:
		Thought* generateThought(Individual& me, const World::ElementsVector& visibleElements,
				float deltaTimeInSeconds);

	private:
		Thought* getRandomMove(const Genotype& genotype, State& state, float deltaTimeInSeconds);
		Thought* getEvadingMove(const Vector& position, const vector<Element*>& blockingElements,
				State& state, const Genotype& genotype, float deltaTimeInSeconds);
		Thought* getEatingMove(Individual& me, const World::ElementsVector& elements,
				float deltaTimeInSeconds);
		Thought* getDrinkingMove(Individual& me, const World::ElementsVector& visibleElements,
				float deltaTimeInSeconds);
		Thought* getMatingMove(Individual& me, const World::ElementsVector& elements,
				float deltaTimeInSeconds);
		vector<Individual*> getMatingIndividuals(bool isCarnivore,
				const World::ElementsVector& elements);
		vector<Supply*> getEatingSupplies(bool isCarnivore, const World::ElementsVector& elements);
		void findWaterSupplies(std::vector<WaterSupply*>& waterSupplies,
				const World::ElementsVector& visibleElements);
		void calculateMassInAngles(const Vector& position, const vector<Element*>& elements,
				State& state, const Genotype& genotype);

};
